package com.tjbank.cssys.web.config;


import com.tjbank.cssys.service.util.IYCPEncryptor;
import org.apache.commons.lang3.StringUtils;

import javax.servlet.http.HttpServletRequest;

public class GetUserCodeFromToken {


    public static String getUserCode(HttpServletRequest httpRequest) throws Exception {
        String token = httpRequest.getHeader("Access-Token");
        String loginCode = null;
        // 2、对token解密,获取登陆码
        if(StringUtils.isNotBlank(token)){
            String decrypt = IYCPEncryptor.decrypt(token);
            loginCode = decrypt.substring(0, decrypt.indexOf("_"));
        }

        return loginCode;
    }
}
